<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Data-Table 表格</title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
</head>
<body class="body">

<!-- 工具集 -->
<div class="my-btn-box">
    <span class="fl">
        <a class="layui-btn btn-add btn-default" id="btn-refresh"><i class="layui-icon">&#x1002;</i></a>
    </span>
    <span class="fr">
        <span class="layui-form-label">搜索条件：</span>
        <div class="layui-input-inline">
            <input type="text" autocomplete="off" placeholder="请输入搜索条件" class="layui-input">
        </div>
        <button class="layui-btn mgl-20">查询</button>
    </span>
</div>

<!-- 表格 -->
<table class="layui-hide" id="dateTable" lay-filter="test"></table>


<script type="text/javascript" src="/res/frame/layui/layui.js"></script>
<script type="text/javascript" src="/res/js/index.js"></script>
<script src="/lib/jquery-1.11.3.min.js"></script>
<script src="/lib/jquery.cookie.js"></script>
<script type="text/javascript">


    // layui方法
    layui.use(['table', 'form', 'layer', 'vip_table'], function () {
        // 操作对象
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , vipTable = layui.vip_table
            , $ = layui.jquery;

        // 表格渲染
        var tableIns = table.render({
            elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
            , height: vipTable.getFullHeight()
            , cols: [[
                {type: 'numbers', fixed: 'left'}
                , {field: 'userName', title: '用户名', width: 120, unresize: true, align: "center"}
                , {field: 'biBetNum', title: '下单金额', width: 180, align: 'center'}
                , {field: 'biWin', title: '输/赢', width: 200, align: 'center'}
                , {field: 'biNum', title: '金额', width: 200, align: 'center'}
                , {field: 'biCreatedate', title: '时间', width: 200, align: 'center'}
            ]]
            , page: true
            , url: '/user/incomeListByPage'
            , method: 'post'
            , contentType: 'application/json'
            , request: {
                pageName: 'pageName' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }, where: {
                "userId": localStorage.getItem("userId")
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                }
            }, response: {
                statusName: 'code' //规定数据状态的字段名称，默认：code
                , statusCode: "200" //规定成功的状态码，默认：0
                , msgName: 'msg' //规定状态信息的字段名称，默认：msg
                , countName: 'count' //规定数据总数的字段名称，默认：count
                , dataName: 'data' //规定数据列表的字段名称，默认：data
            }
            , limits: [30, 60, 90, 150, 300]
            , limit: 30 //默认采用30
            , done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                console.log(res);

                //得到当前页码
                console.log(curr);

                //得到数据总量
                console.log(count);
            }
        });
        // 刷新
        $('#btn-refresh').on('click', function () {
            tableIns.reload();
        });

    });

</script>
</body>
</html>